﻿using System;

public class Mapper087 : MapperDefault
{
    public override void init(NES nes)
    {
        base.init(nes);
    }

    public override void loadROM(ROM rom)
    {
        if (!rom.Valid)
        {
            Console.Out.WriteLine("Invalid ROM! Unable to load.");
        }
        else
        {
            int romBankCount = rom.RomBankCount;
            this.load8kRomBank(0, 0x8000);
            this.load8kRomBank(1, 0xa000);
            this.load8kRomBank(2, 0xc000);
            this.load8kRomBank(3, 0xe000);
            this.loadCHRROM();
            base.nes.Cpu.requestIrq(2);
        }
    }

    public override void writelow(int address, short value_Renamed)
    {
        if (address < 0x6000)
        {
            base.writelow(address, value_Renamed);
        }
        else if (address == 0x6000)
        {
            int num = (value_Renamed & 2) >> 1;
            this.load8kVromBank(num * 8, 0);
        }
    }
}

